﻿<Window x:Class="LevelEditor.View.Windows.AssetsManagerWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:uc="clr-namespace:LevelEditor.View.UserControls"
        xmlns:px="clr-namespace:LevelEditor.Utils.ImageSnappingToPixels"
        xmlns:ut="clr-namespace:LevelEditor.Utils"
        xmlns:mdlEnum="clr-namespace:LevelEditor.Model.Enum"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        Title="Assets Manager" Height="480" Width="640" Icon="/LevelEditor;component/Assets/UI/ico_assetsManager.png">
    <Window.Resources>
        <ut:ConvertUriToImage x:Key="uriToImageConverter" />
        <ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}" x:Key="AssetTypesEnumValues">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="mdlEnum:AssetType"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    </Window.Resources>
    <Grid Grid.Column="3" Width="Auto">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="300" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <DockPanel Grid.Column="0" Name="GameElementDock" LastChildFill="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="Auto">
            <Grid Margin="0" DockPanel.Dock="Top">
                <Rectangle Height="20" Fill="#2d2d2d">
                </Rectangle>
                <Label Foreground="White">Assets</Label>
            </Grid>
            <Border DockPanel.Dock="Top" BorderThickness="1" BorderBrush="#EEEEEE" Margin="2">
                <DockPanel LastChildFill="True" HorizontalAlignment="Stretch" Width="Auto">
                    <Border DockPanel.Dock="Right" Margin="0,4,2,0">
                        <px:Bitmap Source="/Assets/UI/ico_search.png"/>
                    </Border>
                    <TextBox Name="SearchTB" DockPanel.Dock="Left" BorderThickness="0"></TextBox>
                </DockPanel>
            </Border>
            <StackPanel Width="Auto" DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Name="removeAssetBtn" Margin="5,5,5,5" Width="75">Remove</Button>
                <Button Name="addAssetBtn" Margin="0,5,5,5" Width="100">Add Asset(s)</Button>
            </StackPanel>
            <DataGrid AutoGenerateColumns="False"
                      GridLinesVisibility="None"
                      SelectionMode="Extended"
                      SelectionUnit="FullRow"
                      Name="assetsDG"
                      VerticalAlignment="Stretch"
                      HorizontalAlignment="Stretch"
                      Height="Auto"
                      Width="Auto"
                      CanUserAddRows="False"
                      CanUserReorderColumns="True"
                      CanUserResizeColumns="True"
                      CanUserSortColumns="True"
                      ItemsSource="{Binding }" >
                <DataGrid.GroupStyle>
                    <GroupStyle>
                        <GroupStyle.HeaderTemplate>
                            <DataTemplate>
                                <StackPanel>
                                    <TextBlock Text="{Binding Path=Name}" />
                                </StackPanel>
                            </DataTemplate>
                        </GroupStyle.HeaderTemplate>
                        <GroupStyle.ContainerStyle>
                            <Style TargetType="{x:Type GroupItem}">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type GroupItem}">
                                            <Expander IsExpanded="True" HorizontalAlignment="Stretch">
                                                <Expander.Header>
                                                    <StackPanel Orientation="Horizontal">
                                                        <TextBlock Text="{Binding Path=Name}" />
                                                    </StackPanel>
                                                </Expander.Header>
                                                <ItemsPresenter />
                                            </Expander>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </GroupStyle.ContainerStyle>
                    </GroupStyle>
                </DataGrid.GroupStyle>
                <DataGrid.Columns>
                    <DataGridTemplateColumn Header="Img" MinWidth="35">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Image Height="20" Source="{Binding Path=ImageSource, Converter={StaticResource uriToImageConverter}}"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTextColumn Header="Name" Width="*" MinWidth="100" Binding="{Binding Name, Mode=TwoWay}"></DataGridTextColumn>
                    <DataGridTextColumn Header="Category" MinWidth="100" Binding="{Binding Category, Mode=TwoWay}"></DataGridTextColumn>
                    <DataGridComboBoxColumn Header="Type" MinWidth="125"  ItemsSource="{Binding Source={StaticResource AssetTypesEnumValues}}" SelectedValueBinding="{Binding AssetType}"></DataGridComboBoxColumn>
                </DataGrid.Columns>
            </DataGrid>
        </DockPanel>

        <GridSplitter VerticalAlignment="Stretch" Grid.Column="1" Width="5" ResizeDirection="Columns" ResizeBehavior="PreviousAndNext"></GridSplitter>

        <DockPanel Grid.Column="2" LastChildFill="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <Grid Margin="0" DockPanel.Dock="Top">
                <Rectangle Height="20" Fill="#2d2d2d">
                </Rectangle>
                <Label Foreground="White">Manage</Label>
            </Grid>
            <StackPanel Width="Auto" DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Name="closeBtn" Margin="0,5,5,5" Width="75">Close</Button>
            </StackPanel>
            <TabControl Height="Auto">
                <TabItem Name="viewTab" Header="View" Visibility="Collapsed"></TabItem>
                <TabItem Name="editTab" Header="Edit" Visibility="Collapsed">
                    <uc:GameSpriteEditor x:Name="gameSpriteEditor"></uc:GameSpriteEditor>
                </TabItem>
                <TabItem Name="groupsTab"  Header="Groups" Visibility="Collapsed"></TabItem>
            </TabControl>

        </DockPanel>

    </Grid>
</Window>
